package com.hr.controller;

import com.hr.entity.ConfigFileSecondKind;

import com.hr.entity.R;
import com.hr.service.ConfigFileSecondKindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.hr.service.ConfigFileSecondKindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController
@RequestMapping("/configFileSecondKind")
public class ConfigFileSecondKindController {
    @Autowired
    private ConfigFileSecondKindService service;

    /**
     * 查询查询二级机构设置
     * @return
     */
    @RequestMapping("/queryList")
    public List<ConfigFileSecondKind> queryList(
            ConfigFileSecondKind configFileSecondKind){
        List<ConfigFileSecondKind> configFileSecondKinds = service.queryList(configFileSecondKind);
        return  configFileSecondKinds;
    }

    /**
     * 保存/修改
     * @param configFileSecondKind
     * @return
     */
    @PostMapping("/save")
    public R save(
            @RequestBody
            ConfigFileSecondKind configFileSecondKind){
        boolean save = service.save(configFileSecondKind);
        return save ? R.ok("保存成功"):R.fail("保存失败");
    }

    /**
     * 删除
     * @param fskid
     * @return
     */
    @DeleteMapping("/del")
    public R delete(Integer fskid){
        boolean save = service.del(fskid);
        return save ? R.ok("删除成功"):R.fail("删除失败");
    }

    /**
     * 单值查询
     * @param fskid
     * @return
     */
    @RequestMapping("/queryById")
    public ConfigFileSecondKind queryById(Integer fskid) {
        ConfigFileSecondKind configFileSecondKind = service.queryById(fskid);
        return configFileSecondKind;

    }

//    @Autowired
//    private ConfigFileSecondKindService configFileSecondKindService;
//
//    @GetMapping("/queryList")
//    public List<ConfigFileSecondKind> queryList(){
//        List<ConfigFileSecondKind> list = configFileSecondKindService.queryList();
//        System.out.println("*** list"+list);
//        return list;
//    }
}
